/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package it.apuliait.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import it.apuliait.model.DocumentoXml;
import it.apuliait.model.DocumentoXmlModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the DocumentoXml service. Represents a row in the &quot;fatturapa_DocumentoXml&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link it.apuliait.model.DocumentoXmlModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DocumentoXmlImpl}.
 * </p>
 *
 * @author Donatello
 * @see DocumentoXmlImpl
 * @see it.apuliait.model.DocumentoXml
 * @see it.apuliait.model.DocumentoXmlModel
 * @generated
 */
public class DocumentoXmlModelImpl extends BaseModelImpl<DocumentoXml>
	implements DocumentoXmlModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a documento xml model instance should use the {@link it.apuliait.model.DocumentoXml} interface instead.
	 */
	public static final String TABLE_NAME = "fatturapa_DocumentoXml";
	public static final Object[][] TABLE_COLUMNS = {
			{ "documentoXmlId", Types.BIGINT },
			{ "documentoIDFK", Types.BIGINT },
			{ "annoCreazione", Types.VARCHAR },
			{ "documentoXml", Types.CLOB }
		};
	public static final String TABLE_SQL_CREATE = "create table fatturapa_DocumentoXml (documentoXmlId LONG not null primary key,documentoIDFK LONG,annoCreazione VARCHAR(75) null,documentoXml TEXT null)";
	public static final String TABLE_SQL_DROP = "drop table fatturapa_DocumentoXml";
	public static final String ORDER_BY_JPQL = " ORDER BY documentoXml.documentoXmlId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY fatturapa_DocumentoXml.documentoXmlId ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.it.apuliait.model.DocumentoXml"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.it.apuliait.model.DocumentoXml"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.it.apuliait.model.DocumentoXml"),
			true);
	public static long DOCUMENTOIDFK_COLUMN_BITMASK = 1L;
	public static long DOCUMENTOXMLID_COLUMN_BITMASK = 2L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.it.apuliait.model.DocumentoXml"));

	public DocumentoXmlModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _documentoXmlId;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setDocumentoXmlId(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _documentoXmlId;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return DocumentoXml.class;
	}

	@Override
	public String getModelClassName() {
		return DocumentoXml.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("documentoXmlId", getDocumentoXmlId());
		attributes.put("documentoIDFK", getDocumentoIDFK());
		attributes.put("annoCreazione", getAnnoCreazione());
		attributes.put("documentoXml", getDocumentoXml());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long documentoXmlId = (Long)attributes.get("documentoXmlId");

		if (documentoXmlId != null) {
			setDocumentoXmlId(documentoXmlId);
		}

		Long documentoIDFK = (Long)attributes.get("documentoIDFK");

		if (documentoIDFK != null) {
			setDocumentoIDFK(documentoIDFK);
		}

		String annoCreazione = (String)attributes.get("annoCreazione");

		if (annoCreazione != null) {
			setAnnoCreazione(annoCreazione);
		}

		String documentoXml = (String)attributes.get("documentoXml");

		if (documentoXml != null) {
			setDocumentoXml(documentoXml);
		}
	}

	@Override
	public long getDocumentoXmlId() {
		return _documentoXmlId;
	}

	@Override
	public void setDocumentoXmlId(long documentoXmlId) {
		_documentoXmlId = documentoXmlId;
	}

	@Override
	public long getDocumentoIDFK() {
		return _documentoIDFK;
	}

	@Override
	public void setDocumentoIDFK(long documentoIDFK) {
		_columnBitmask |= DOCUMENTOIDFK_COLUMN_BITMASK;

		if (!_setOriginalDocumentoIDFK) {
			_setOriginalDocumentoIDFK = true;

			_originalDocumentoIDFK = _documentoIDFK;
		}

		_documentoIDFK = documentoIDFK;
	}

	public long getOriginalDocumentoIDFK() {
		return _originalDocumentoIDFK;
	}

	@Override
	public String getAnnoCreazione() {
		if (_annoCreazione == null) {
			return StringPool.BLANK;
		}
		else {
			return _annoCreazione;
		}
	}

	@Override
	public void setAnnoCreazione(String annoCreazione) {
		_annoCreazione = annoCreazione;
	}

	@Override
	public String getDocumentoXml() {
		if (_documentoXml == null) {
			return StringPool.BLANK;
		}
		else {
			return _documentoXml;
		}
	}

	@Override
	public void setDocumentoXml(String documentoXml) {
		_documentoXml = documentoXml;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			DocumentoXml.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public DocumentoXml toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (DocumentoXml)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		DocumentoXmlImpl documentoXmlImpl = new DocumentoXmlImpl();

		documentoXmlImpl.setDocumentoXmlId(getDocumentoXmlId());
		documentoXmlImpl.setDocumentoIDFK(getDocumentoIDFK());
		documentoXmlImpl.setAnnoCreazione(getAnnoCreazione());
		documentoXmlImpl.setDocumentoXml(getDocumentoXml());

		documentoXmlImpl.resetOriginalValues();

		return documentoXmlImpl;
	}

	@Override
	public int compareTo(DocumentoXml documentoXml) {
		long primaryKey = documentoXml.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof DocumentoXml)) {
			return false;
		}

		DocumentoXml documentoXml = (DocumentoXml)obj;

		long primaryKey = documentoXml.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		DocumentoXmlModelImpl documentoXmlModelImpl = this;

		documentoXmlModelImpl._originalDocumentoIDFK = documentoXmlModelImpl._documentoIDFK;

		documentoXmlModelImpl._setOriginalDocumentoIDFK = false;

		documentoXmlModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<DocumentoXml> toCacheModel() {
		DocumentoXmlCacheModel documentoXmlCacheModel = new DocumentoXmlCacheModel();

		documentoXmlCacheModel.documentoXmlId = getDocumentoXmlId();

		documentoXmlCacheModel.documentoIDFK = getDocumentoIDFK();

		documentoXmlCacheModel.annoCreazione = getAnnoCreazione();

		String annoCreazione = documentoXmlCacheModel.annoCreazione;

		if ((annoCreazione != null) && (annoCreazione.length() == 0)) {
			documentoXmlCacheModel.annoCreazione = null;
		}

		documentoXmlCacheModel.documentoXml = getDocumentoXml();

		String documentoXml = documentoXmlCacheModel.documentoXml;

		if ((documentoXml != null) && (documentoXml.length() == 0)) {
			documentoXmlCacheModel.documentoXml = null;
		}

		return documentoXmlCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(9);

		sb.append("{documentoXmlId=");
		sb.append(getDocumentoXmlId());
		sb.append(", documentoIDFK=");
		sb.append(getDocumentoIDFK());
		sb.append(", annoCreazione=");
		sb.append(getAnnoCreazione());
		sb.append(", documentoXml=");
		sb.append(getDocumentoXml());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(16);

		sb.append("<model><model-name>");
		sb.append("it.apuliait.model.DocumentoXml");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>documentoXmlId</column-name><column-value><![CDATA[");
		sb.append(getDocumentoXmlId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>documentoIDFK</column-name><column-value><![CDATA[");
		sb.append(getDocumentoIDFK());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>annoCreazione</column-name><column-value><![CDATA[");
		sb.append(getAnnoCreazione());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>documentoXml</column-name><column-value><![CDATA[");
		sb.append(getDocumentoXml());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = DocumentoXml.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			DocumentoXml.class
		};
	private long _documentoXmlId;
	private long _documentoIDFK;
	private long _originalDocumentoIDFK;
	private boolean _setOriginalDocumentoIDFK;
	private String _annoCreazione;
	private String _documentoXml;
	private long _columnBitmask;
	private DocumentoXml _escapedModel;
}